//
//  ZLZhushiViewController.m
//  LittleFairyPoet
//
//  Created by rimi on 15/9/14.
//  Copyright (c) 2015年 周林. All rights reserved.
//

#import "ZLZhushiViewController.h"

@interface ZLZhushiViewController ()

@property (nonatomic, strong) UILabel *zhushiLabel /**< 正文 */;
@property (nonatomic, strong) UIScrollView *mainScrollView /**< 滚动视图 */;
- (void) initializeUserInterface; /**< 初始化用户界面 */
@end

@implementation ZLZhushiViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initializeUserInterface];
    
}

#pragma mark - init
- (void)initializeUserInterface {
    self.view.backgroundColor = [UIColor whiteColor];
    [self.mainScrollView addSubview:self.zhushiLabel];
    [self.view addSubview:self.mainScrollView];
    self.mainScrollView.contentSize = CGSizeMake(0, CGRectGetMaxY(self.zhushiLabel.frame));
    self.titleLable.text = @"译文";
}

#pragma mark - getter
- (UILabel *)zhushiLabel {
    if (!_zhushiLabel) {
        _zhushiLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, ORIGIN_WIDTH, ORIGIN_HEIGHT) adjustWidth:NO];
        NSString *string = self.poem[@"yiwen"];
        NSMutableAttributedString *contetString = [[NSMutableAttributedString alloc]initWithString:string attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14]}];
        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
        paragraphStyle.lineSpacing = 10;
        [contetString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, string.length)];
        _zhushiLabel.attributedText = contetString;
        _zhushiLabel.numberOfLines = 0;
        [_zhushiLabel sizeToFit];
        _zhushiLabel.center = DHFlexibleCenter(CGPointMake(ORIGIN_WIDTH / 2, _zhushiLabel.bounds.size.height / 2));
    }
    return _zhushiLabel;
}

- (UIScrollView *)mainScrollView {
    if (!_mainScrollView) {
        _mainScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 64, ORIGIN_WIDTH, ORIGIN_HEIGHT - 64) adjustWidth:NO];
    }
    return _mainScrollView;
}
@end
